#ifndef AUDIO_TO_WAVE_EXPORT_2015_02_10_H
#define AUDIO_TO_WAVE_EXPORT_2015_02_10_H

#ifdef __cplusplus
extern "C"{
#endif	// __cplusplus
    
#ifdef _WIN32
#define AUDIO2WAV_EXPORTAPI __declspec(dllexport)
#else
#define __stdcall
#define AUDIO2WAV_EXPORTAPI
#endif  // _WIN32

/** WAVE structure
 * WAV header to the output file.
 */
typedef struct tag_wavhdr {
    int     RIFF;	///< 'R','I','F','F'
    int     size;	///< size of wave file from here on
    int     WAVE;	///< 'W','A','V','E'
    int     fmt;	///< 'f','m','t',' '
    int     wFormatLength;	///< The length of the TAG format
    short	wFormatTag;     ///< should be 1 for PCM type data
    short	nChannels;      ///< should be 1 for MONO type data
    int     nSamplesPerSec;	///< should be 11025, 22050, 44100
    int     nAvgBytesPerSec;///< Average Data Rate
    short	nBlockAlign;    ///< 1 for 8 bit data, 2 for 16 bit
    short	wBitsPerSample;///< 8 for 8 bit data, 16 for 16 bit
    int     data;	///< 'd','a','t','a'
    int     dSize;	///< size of data from here on
} wavhdr;

/** The callback is used to send reporting information back to the calling code
 * while it is decoding.
 * @param FrameCnt 1-based frame count
 * @param InByteTot total Bytes befor this frame being decoded
 * @param Header header of mp3 frame
 */
typedef void (__stdcall *LPMadCallback)(unsigned int FrameCnt, unsigned int InByteTot, void *Header);
AUDIO2WAV_EXPORTAPI
int __stdcall MpegDecoder(const char *szInFile, const char *szOutFile, int fWaveFile,
						  char *lpszMsg, int nMaxMsgSize, LPMadCallback CbFunc);

/** nType: [1, 4]
 * 1 --- 2 integers, {nChannel, nSampleRate}
 * 2 --- pcm wave data, lpData is in short
 * 3 --- 4 integers, {frameCount, seconds, timeFraction, timeUnit}
 * 4 --- 1 integer, {totalOutputBytes}
 */
typedef void (__stdcall *LPDecodeCallback)(void *lpContext, int nType, const unsigned char *lpData, int nBytes);
AUDIO2WAV_EXPORTAPI
int __stdcall MpegDecodeWithCallback(const char *szInFile, char *lpError, int nMaxError, LPDecodeCallback lpfnCallback, void *lpContext);
#ifdef __cplusplus
}
#endif	// __cplusplus

#endif	// AUDIO_TO_WAVE_EXPORT_2015_02_10_H
